<?php

    /**
    * Список лечебных учреждений, к которым прикреплен пациент
    * т.е. там, где у него имеется амбулаторная карта
    */
    class LpuList
    {
        public $List = Array();
        function __construct($person)
        {
            global $mikron;
            $guid = $person->uniqueid->value;
            $req_xml = getLPUListXML($guid);
            $lpu_xml = CallSoap('getlpulist', $req_xml);
            $dom1 = new DomDocument();
            $dom1->loadXML($lpu_xml);
            $lpulist = $dom1->getElementsByTagName("lpulist");
            foreach($lpulist as $list)
            {
                $lpus = $list->getElementsByTagName("lpu");
                foreach($lpus as $lpu)
                {
                    $guid = $lpu->getAttribute('guid');
                    $name = $lpu->getAttribute('name');
                    $address = $lpu->getAttribute('address');
                    $this->addLpu($guid, $name, $address, $person);
                }
            }
            $mikron->Cache->setCache('lpulist_cache', $this->List);
        }
        public function addLpu($guid, $name, $address, $person)
        {
            /*
            global $mikron;
            $personLpu = new PERSONLPU();
            $personLpu->guid->value = $guid;
            $personLpu->name->value = $name;
            $personLpu->address->value = $address;
            $personLpu->person->value = $person->id;
            $this->List[] = $personLpu;*/
            $this->List[] = Array('guid'=>$guid, 'name'=>$name, 'address'=>$address, 'person'=>$person->id );
        }
    }

?>